package Servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAO.DBCon;

/**
 * Servlet implementation class EDIChangeIn
 */
@WebServlet("/EDIChangeIn")
public class EDIChangeIn extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EDIChangeIn() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String dept = new String(request.getParameter("insert").getBytes("iso-8859-1"), "utf-8");
		String sql = "Insert into edit91 values(\""+dept+"\")";
		DBCon dbCon = new DBCon();
		Connection connection = dbCon.getConnection();
		try{
			PreparedStatement stmt = connection.prepareStatement(sql);
			stmt.executeUpdate();
			
			stmt.close();
			connection.close();
			
			response.setHeader("refresh", "1;url=EDIChange.jsp");
		}catch(Exception e){
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
